<%= simple_form_for(@order, html: { class: 'form-horizontal' }  ) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="row">
  <div class="col-md-6">
    <%= f.collection_radio_buttons :order_type, [['TEMP','临时订单'],['REG','正式订单']], :first, :last, :checked =>['TEMP','临时订单'],  item_wrapper_class: 'col-md-3 default', item_label_class: 'default' %>
  </div>
</div>

<div class="row">
  <div class="col-md-4">
    <div class="form-group date required order_order_date form-group-valid">
      <label class="form-control-label select required" for="order_order_date_1i">订单日期</label>
      <div class="input-group">
        <input name="order[order_date]" value="<%= @order.order_date %>" class="form-control select required date-picker " id="order_po_date" type="text" data-date-format="yyyy-mm-dd">
        <span class="input-group-addon"> <i class="fa fa-calendar"></i> </span>
      </div>
    </div>
  </div>
  <div class="col-md-4">
		<%= f.input :order_code, label: '订单号' %>
	</div>
  <div class="col-md-4">
    <%= f.input :customer_po, label: '客户订单号' %>
  </div>
</div>
<div class="row">
	<div class="col-md-4">
		<%= f.association :customer, label_method: :name, value_method: :id , label: '客户' %>
	</div>
  <div class="col-md-4">
    <%= f.input :amount , label: '金额'%>
  </div>
  <div class="col-md-4">
    <%= f.input :payment_term , label: '付款方式'%>
  </div>
</div>

<div class="row">
	<div class="col-md-4">
		<!-- <%= f.input :due_date, label: '交期' %> -->
		<div class="form-group date required order_due_date form-group-valid">
			<label class="form-control-label date required" for="order_due_date">交期</label>
			<div class="input-group">
				<input name="order[due_date]" class="form-control date-picker" id="order_due_date" type="text" data-date-format="yyyy-mm-dd">
				<span class="input-group-addon"> <i class="fa fa-calendar"></i> </span>
			</div>
		</div>
	</div>
	<div class="col-md-4">
		<%= f.input :contract_no , label: '合同号'%>
	</div>
  <div class="col-md-4">
    <%= f.input :tieta_settlement_no , label: '铁塔财务报账号'%>
  </div>
</div>

<div class="row">
	<div class="col-md-4">
		<%= f.input :contract_no , label: '收货地址' %>
	</div>
	<div class="col-md-4">
		<%= f.input :tieta_settlement_no , label: '收货人' %>
	</div>
  <div class="col-md-4">
    <%= f.input :contract_no , label: '收货人电话'%>
  </div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="form-title"></div>

	</div>
</div>
<div class="row">
	<div class="col-md-12">

		<table id="invoice" class="table table-bordered" >
			<thead>
				<tr>
					<th class="col-sm-2"> 物料编码</th>
					<th class="col-sm-2"> 产品名称</th>
					<th class="col-sm-2"> 规格型号</th>
					<th class="col-sm-1"> 单位</th>
					<th class="col-sm-1"> 数量 </th>
					<th class="col-sm-1"> 单价 </th>
					<th class="col-sm-1"> 税率 </th>
					<th class="col-sm-1"> 金额 </th>
					<th class="col-sm-1"> 备注 </th>
					<th class="col-sm-1"></th>
				</tr>
			</thead>
			<tbody id="items">
				<%= f.simple_fields_for :order_items  do |task| %>
				<%= render 'item_fields', :f => task %>
				<% end %>
			</tbody>
			<tfoot>
				<tr>
					<th colspan="2" class="caption">合计</th>
					<th></th>
					<th></th>
				</tr>

			</tfoot>
		</table>
		<%= link_to_add_association '<i class="fa fa-plus"></i>'.html_safe+'添加产品', f, :items, :data => { "association-insertion-node" => '#invoice tbody', "association-insertion-method" => 'append'}, class: "btn btn-default" %>
	</div>
</div>

<div class="row">
	<div class="col-md-12">
		<div class="form-title"></div>

	</div>
</div>
<div class="row">
	<div class="col-md-12">
		<%= f.input :comment, label: '备注' %>
	</div>

</div>
<div class="horizontal-space"></div>
<div class="form-actions">
	<%= f.button :submit, '提交',class: "btn btn-blue btn-xs" %>
</div>
<% end %>
